const Koa = require('koa');
const cors = require('koa2-cors');
const bodyParser = require('koa-bodyparser');
const static = require('koa-static')
const path = require('path')
const app = new Koa();

// 导入文件
const student = require('./modules/student')
const course = require("./modules/course")
const users = require("./modules/users")
const denglu = require("./modules/denglu")
const campus = require("./modules/campus")
const clbum = require("./modules/clbum")
const classhour = require("./modules/classhour")
const classroom = require("./modules/classroom")
const teacher = require("./modules/teacher")
const banner = require("./modules/banner")
const information = require("./modules/information")
const activity = require("./modules/activity")
const activityinfo = require("./modules/activityinfo")
const pbclass = require("./modules/pbclass")
const pbclassinfo = require("./modules/pbclassinfo")
const staff = require("./modules/staff")
const generalSettings = require("./modules/generalSettings")
const aboutUs = require("./modules/aboutUs")
const sysmsg = require("./modules/sysmsg")
const appmsg = require("./modules/appmsg")
const indent = require("./modules/indent")
const seckill = require("./modules/seckill")
const setcourse = require("./modules/setcourse")
const discoupon = require("./modules/discoupon")
const discoupondetail = require("./modules/discoupondetail")
const opalog = require("./modules/opalog")
const role = require("./modules/role")


// 使用文件
app.use(cors())
app.use(bodyParser());
app.use(static(path.join(__dirname, 'uploads')))

app.use(course.routes(), course.allowedMethods())
app.use(indent.routes(), indent.allowedMethods())
app.use(role.routes(), role.allowedMethods())
app.use(users.routes(), users.allowedMethods())
app.use(student.routes(), student.allowedMethods())
app.use(denglu.routes(), denglu.allowedMethods())
app.use(campus.routes(), campus.allowedMethods())
app.use(clbum.routes(), clbum.allowedMethods())
app.use(classhour.routes(), classhour.allowedMethods())
app.use(classroom.routes(), classroom.allowedMethods())
app.use(teacher.routes(), teacher.allowedMethods())
app.use(staff.routes(), staff.allowedMethods())
app.use(generalSettings.routes(), generalSettings.allowedMethods())
app.use(aboutUs.routes(), aboutUs.allowedMethods())
app.use(banner.routes(), banner.allowedMethods())
app.use(information.routes(), information.allowedMethods())
app.use(activity.routes(), activity.allowedMethods())
app.use(activityinfo.routes(), activityinfo.allowedMethods())
app.use(pbclass.routes(), pbclass.allowedMethods())
app.use(pbclassinfo.routes(), pbclassinfo.allowedMethods())
app.use(sysmsg.routes(), sysmsg.allowedMethods())
app.use(appmsg.routes(), appmsg.allowedMethods())
app.use(seckill.routes(), seckill.allowedMethods())
app.use(setcourse.routes(), setcourse.allowedMethods())
app.use(discoupon.routes(), discoupon.allowedMethods())
app.use(discoupondetail.routes(), discoupondetail.allowedMethods())
app.use(opalog.routes(), opalog.allowedMethods())

app.listen(3004, () => {
    console.log('服务启动成功 已在3004端口打开');
});